package com.example.com.common.app;

import com.example.com.common.factory.data.DataSource;
import com.example.com.common.factory.data.DbDataSource;

import java.util.List;

/**
 * 基础仓库源的presenter定义
 * Created by ChenYiYao on 2018/12/5.
 */
public abstract class BaseSourcePresenter<Data, Source extends DbDataSource<Data>,
        View extends BaseContract.View> extends BasePresenter<View>
        implements DataSource.SucceedCallback<List<Data>> {
    //数据仓库
    protected Source mSource;

    public BaseSourcePresenter(Source source,View view) {
        super(view);
        this.mSource =source;
    }

    @Override
    public void start() {
        super.start();
        loadSource();
    }

    /**
     * 加载数据仓库数据
     */
    public abstract void loadSource();

    @Override
    public void destroy() {
        super.destroy();
        mSource.dispose();
        mSource=null;
    }
}
